/**
 *
 */
package steven.common.android;

import android.content.Context;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author Steven
 *
 */
public class UserInterfaceUtils{
	protected UserInterfaceUtils(){
	}
	public static final ImageView createImage(final Context context, final int resId, final OnTouchListener listener){
		final ImageView v = new ImageView(context);
		v.setImageResource(resId);
		if(listener != null){
			v.setOnTouchListener(listener);
		}
		return v;
	}
	public static final Button createButton(final Context context, final int resId, final OnClickListener listener){
		final Button v = new Button(context);
		UserInterfaceUtils.modifyButton(v, resId, listener);
		return v;
	}
	public static final void modifyButton(final Button button, final int resId, final OnClickListener listener){
		button.setText(resId);
		button.setOnClickListener(listener);
	}
	public static final Button createButton(final Context context, final String text, final OnClickListener listener){
		final Button v = new Button(context);
		UserInterfaceUtils.modifyButton(v, text, listener);
		return v;
	}
	public static final void modifyButton(final Button button, final String text, final OnClickListener listener){
		button.setText(text);
		button.setOnClickListener(listener);
	}
	public static final TextView createText(final Context context, final String text){
		final TextView v = new TextView(context);
		if(text != null){
			v.setText(text);
		}
		return v;
	}
}
